package gold.digger;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC804 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        private String[] map = {
                ".-",
                "-...",
                "-.-.",
                "-..",
                ".",
                "..-.",
                "--.",
                "....",
                "..",
                ".---",
                "-.-",
                ".-..",
                "--",
                "-.",
                "---",
                ".--.",
                "--.-",
                ".-.",
                "...",
                "-",
                "..-",
                "...-",
                ".--",
                "-..-",
                "-.--",
                "--.."
        };

        public int uniqueMorseRepresentations(String[] words) {
            if (words == null) return 0;
            HashSet<String> set = new HashSet<String>();
            for (String s : words) {
                StringBuilder sb = new StringBuilder();
                for (char c : s.toCharArray()) {
                    sb.append(map[c - 'a']);
                }
                set.add(sb.toString());
            }
            return set.size();
        }
    }

    public void run() {
        int[] arr = InputUtil.toIntegerArray("[1,2,3]");
        System.out.println(new Solution().toString());
    }

    public static void main(String[] args) throws Exception {
        LC804 an = new LC804();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
